package com.jiafa.wjxt.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * Created by jiafa
 * on 2021/5/27 12:24
 * 异步统一返回结果封装
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    private Integer code;
    private String msg;
    private Object data;

    public static Result build(){
        return new Result();
    }

    public static Result success(String msg){
        return new Result(200,msg,null);
    }

    public static Result ok(String projectKey){
        return new Result(200,null,projectKey);
    }

    public static Result success(String msg, Object data){
        return new Result(200,msg,data);
    }

    public static Result error(String msg){
        return new Result(500,msg,null);
    }

    public static Result error(String msg, Object obj) {
        return new Result(500, msg, obj);
    }
}
